package com.example.demo.T2.util;

import java.util.Random;

/**
 * TollCheckTime.. 计时策略，演示时间为s
 *
 * @author Lizhong
 * @date 2020/8/18
 */
public class TollCheckTime {

    int minMinutes;
    int maxMinutes;

    public TollCheckTime() {
    }

    public TollCheckTime(int minMinutes, int maxMinutes) {
        if (minMinutes > maxMinutes) throw new RuntimeException("minMinutes not rather than maxMinutes ");
        this.minMinutes = minMinutes;
        this.maxMinutes = maxMinutes;
    }

    /**
     * 生成范围随机数
     * @return
     */
    public int getWaitingTime() {
        Random random = new Random();
        return random.nextInt(maxMinutes) %(maxMinutes - minMinutes + 1) + minMinutes;
    }

    /**
     * 计算平均值
     * @return
     */
    public int getAverageTime() {
        return (minMinutes + maxMinutes) / 2;
    }



}
